package com.medical.device.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.medical.device.Application;
import com.medical.device.common.R;

import com.medical.device.entity.Demo03;
import com.medical.device.service.impl.Demo03ServiceImpl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 86152
 * @since 2020-08-02
 */
@Api(tags = "Demo03Controller")
@RestController
@RequestMapping("/demo03")
public class Demo03Controller {

    private static final Logger logger = LoggerFactory.getLogger(Application.class);

    @Autowired
    Demo03ServiceImpl mDemo03ServiceImpl;

    @ApiOperation(value = "", response = Demo03.class)
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ResponseEntity get(Integer id) {
        try {
            Demo03 data = mDemo03ServiceImpl.getById(id);
            if (null==data) {
                return new ResponseEntity(R.error("没有数据"), HttpStatus.NOT_FOUND);
            }
            return ResponseEntity.ok(R.success(data));
        } catch (Exception e) {
            logger.error(e.getMessage());
            return new ResponseEntity(R.error(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}

